<!DOCTYPE html>
<html lang="zh"
      xmlns:th="http://www.thymeleaf.org">
    <head th:replace="common/fragment::top">

    </head>

    <body>
        <div class="lyear-layout-web">
            <div class="lyear-layout-container">
                <!--左侧导航-->
                <div th:replace="common/fragment::leftmenu"></div>
                <!--End 左侧导航-->

                <!--头部信息-->
                <div th:replace="common/fragment::header"></div>
                <!--End 头部信息-->

                <!--页面主要内容-->
                <main class="lyear-layout-content">

                    <div class="container-fluid">

                        <div class="row">
                            <div class="col-lg-12">
                                <div class="card">
                                    <div class="card-toolbar clearfix">
                                        <div class="toolbar-btn-action">
                                            <a class="btn btn-primary m-r-5"
                                               href="/menu/addmenu.do">
                                                <i class="mdi mdi-plus"></i>
                                                新增
                                            </a>
                                            <!--
                                            <a class="btn btn-success m-r-5" href="#!"><i class="mdi mdi-check"></i> 启用</a>
                                            <a class="btn btn-warning m-r-5" href="#!"><i class="mdi mdi-block-helper"></i> 禁用</a>
                                            <a class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a>
                                            -->
                                        </div>
                                    </div>
                                    <div class="card-body">
                                        <div class="table-responsive">
                                            <table class="table table-bordered">
                                                <thead>
                                                    <tr>
                                                        <!--<th>
                                                            <label class="lyear-checkbox checkbox-primary">
                                                                <input type="checkbox" id="check-all">
                                                                <span></span>
                                                            </label>
                                                        </th>-->
                                                        <th>序号</th>
                                                        <th hidden="hidden">id</th>
                                                        <th>菜单名称</th>
                                                        <th>图标</th>
                                                        <th>url</th>
                                                        <th>索引位</th>
                                                        <th>父菜单id</th>
                                                        <th>是否显示</th>
                                                        <th>操作</th>
                                                    </tr>
                                                </thead>
                                                <tbody th:each="menuPO:${menuList}">
                                                    <tr>

                                                        <!-- <td>
                                                             <label class="lyear-checkbox checkbox-primary">
                                                                 <input type="checkbox" name="ids[]" value="1">
                                                                 <span></span>
                                                             </label>
                                                         </td>-->
                                                        <td th:text="${menuPOStat.index+1}"></td>
                                                        <td
                                                                hidden="hidden"
                                                                th:text="${menuPO.id}"></td>

                                                        <td
                                                                th:if="${menuPO.parent.id}==1"
                                                                th:text="${menuPO.menuname}"
                                                                th:with="topmenu=${menuPO.menuname}"></td>
                                                        <td
                                                                th:if="${menuPO.parent.id}!=1"
                                                                th:text="'&emsp;&emsp;&emsp;&emsp;|---->'+${menuPO.menuname}"></td>
                                                        <td>
                                                            <span th:class="'mdi '+${menuPO.icon}">
                                                            </span>
                                                            <span th:text="${menuPO.icon}">
                                                            </span>
                                                        </td>
                                                        <td th:text="${menuPO.url}"></td>
                                                        <td th:text="${menuPO.position}"></td>
                                                        <td th:text="${menuPO.parent.id}"></td>
                                                        <td th:text="${menuPO.display}?显示:不显示"></td>
                                                        <td>
                                                            <div class="btn-group">
                                                                <a
                                                                        class="btn btn-xs btn-default"
                                                                        data-toggle="tooltip"
                                                                        th:href="'/menu/editmenu.do?id='+${menuPO.id}"
                                                                        title="编辑">
                                                                    <i class="mdi mdi-pencil"></i>
                                                                </a>
                                                            <!--    <a
                                                                        class="btn btn-xs btn-default"
                                                                        data-toggle="tooltip"
                                                                        href="javascript:void(0)"
                                                                        th:onclick="deletemenu([[${menuPO.id}]],[[${menuPO.menuname}]])"
                                                                        th:onclick="'javascript:deleterole(\''+${rolePO.id}+'\',\''+${rolePO.name}+'\')'"
                                                                        title="删除">-->
                                                                    <a
                                                                            class="btn btn-xs btn-default"
                                                                            data-toggle="tooltip"
                                                                            href="javascript:void(0)"
                                                                            th:onclick="deletemenu([[${menuPO.id}]],[[${menuPO.menuname}]])"
                                                                            title="删除">
                                                                    <i class="mdi mdi-window-close"></i>
                                                                </a>
                                                            </div>
                                                        </td>
                                                    </tr>

                                                </tbody>
                                            </table>
                                        </div>
                                        <!--
                                        <ul class="pagination">
                                          <li class="disabled"><span>«</span></li>
                                          <li class="active"><span>1</span></li>
                                          <li><a href="#1">2</a></li>
                                          <li><a href="#1">3</a></li>
                                          <li><a href="#1">4</a></li>
                                          <li class="disabled"><span>...</span></li>
                                          <li><a href="#!">14452</a></li>
                                          <li><a href="#!">14453</a></li>
                                          <li><a href="#!">»</a></li>
                                        </ul>
                                        -->
                                    </div>
                                </div>
                            </div>

                        </div>

                    </div>
                </main>
                <!--End 页面主要内容-->
                <!--End 页面主要内容-->
            </div>
        </div>
        <div th:replace="common/fragment::tail-script"></div>
        <script type="text/javascript">
            function deletemenu(menuid, menuname) {
                $.confirm({
                    title: '确定删除？',
                    content: '是否要删除菜单: ' + menuname,
                    type: 'orange',
                    typeAnimated: false,
                    buttons: {
                        confirm: {
                            text: '确认',
                            action: function () {
                                let data = {"id": menuid}
                                post_ajax('/menu/deletemenu.ajax', data, '/menu/listmenu.do')
                            }
                        },
                        cancel: {
                            text: '取消',
                            action: function () {

                            }
                        }
                    }
                });

            }

            $(document).ready(
                // $(".delete-menu-btn").on('click', function (e) {
                //     e.preventDefault()
                //     let postid = $(this).attr('value')
                //     let data = {
                //         'postid': postid,
                //     }
                //
                //     post_ajax('/menu/deletemenu.ajax', data, '/menu/listmenu.do')
                //     // return false;
                //
                //
                // })
            );

        </script>
    </body>
</html>